package hl.demosample.ui.fragment.me

import android.os.Bundle
import androidx.lifecycle.Observer
import androidx.navigation.NavController
import hl.demosample.R
import hl.demosample.app.appViewModel
import hl.demosample.app.base.BaseFragment
import hl.demosample.app.ext.setUiTheme
import hl.demosample.databinding.FragmentMeBinding
import hl.demosample.viewmodel.state.MeViewModel
import kotlinx.android.synthetic.main.fragment_me.*
import me.hgj.jetpackmvvm.ext.nav
import me.hgj.jetpackmvvm.ext.navigateAction

/*
* path: DemoSample 
* Author: 86133
* Create: 2021-06-01 16:14
* Changes (from 2021-06-01)
* Desc:
*/
class MeFragment : BaseFragment<MeViewModel, FragmentMeBinding>() {

    override fun layoutId() = R.layout.fragment_me

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.vm = mViewModel
        mDatabind.click = ProxyClick()
        appViewModel.appColor.value?.let { setUiTheme(it, me_linear) }
    }

    override fun createObserver() {
        appViewModel.run {
            appColor.observeInFragment(this@MeFragment, Observer {
                setUiTheme(it, me_linear, me_swipe)
            })
        }
    }

    inner class ProxyClick {

        fun login() {

        }

        fun collect() {
            nav().navigateAction(R.id.action_mainfragment_to_welfareFragment)
        }

        fun weekHot(){
            nav().navigateAction(R.id.action_mainfragment_to_weekHotFragment)
        }

        fun mGirl(){
            nav().navigateAction(R.id.action_mainfragment_to_girlClassifyFragment)
        }

        fun setting(){
            nav().navigateAction(R.id.action_mainfragment_to_settingFragment)
        }
    }
}